<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex align-stretch benben-position-layout flex bindWechat_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex align-center justify-between flex-sub bindWechat_fd0_0'>
          <view class='flex align-center bindWechat_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
            <text class='fu-iconfont2  bindWechat_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex align-center'>
            <text class='bindWechat_fd0_0_c1_c0'>绑定微信</text>
          </view>
          <view class='flex align-center bindWechat_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---绑定flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout bindWechat_flex_1">
        <view class='flex flex-direction align-stretch bindWechat_fd1_0'>
          <view class='flex flex-wrap align-center bindWechat_fd1_0_c0'>
            <text class='bindWechat_fd1_0_c0_c0'>第一步：先获取手机验证码</text>
          </view>
          <view class='flex flex-wrap align-center bindWechat_fd1_0_c1'>
            <text class='bindWechat_fd1_0_c1_c0'>绑定的用户手机</text>
            <text class='bindWechat_fd1_0_c1_c0'>{{dataMessage.mobile}}</text>
          </view>
          <view class='flex flex-wrap align-center bindWechat_fd1_0_c2'>
            <text class='bindWechat_fd1_0_c2_c0'>验证码</text>
            <benben-input class='flex-sub bindWechat_fd1_0_c2_c1' type="number" :placeholder="`请输入验证码`"
              confirm-type="done" :maxlength="4" placeholder-style="color:#BFBFBF;font-size:28rpx" v-model="code" />
            <benben-send-verification-code key='1689818850301' ref="vCode1689818850301" class=' bindWechat_fd1_0_c2_c2'
              after-text='后重新获取' before-text='获取验证码' type='3'
              :phone="dataMessage._mobile"></benben-send-verification-code>
          </view>
          <view class='flex flex-wrap align-center bindWechat_fd1_0_c3'>
            <text class='bindWechat_fd1_0_c0_c0'>第二步：上传微信收款二维码</text>
          </view>
          <view class='flex flex-direction flex-wrap align-start bindWechat_fd1_0_c4'>
            <view class='flex flex-wrap align-center'>
              <view class="upload position-relative bindWechat_fd1_0_c4_c0_c0">
                <text v-if="databangding.qrcode_url != ''" @tap="databangding.qrcode_url = ''"
                  class='fu-iconfont2 position-absolute bindWechat_fd1_0_c4_c0_c0_icon'>&#xE8E7;</text>
                <image class=" bindWechat_fd1_0_c4_c0_c0" mode="aspectFit"
                  @tap="soloChooseImage('qrcode_url','qrcode_url',databangding,databangding)"
                  :src="databangding.qrcode_url ? databangding.qrcode_url : STATIC_URL+'99.png'"></image>
              </view>
            </view>
            <text class='bindWechat_fd1_0_c4_c1'>上传二维码</text>
          </view>
          <view class='flex flex-wrap align-center bindWechat_fd1_0_c1'>
            <text class='bindWechat_fd1_0_c0_c0'>第三步：填写微信真实姓名</text>
          </view>
          <view class='flex flex-wrap align-center bindWechat_fd1_0_c6'>
            <text class='bindWechat_fd1_0_c6_c0'>真实姓名</text>
            <benben-input class='flex-sub bindWechat_fd1_0_c2_c1' type="text" :placeholder="`请输入真实姓名`"
              confirm-type="done" :maxlength="7" placeholder-style="color:#BFBFBF;font-size:28rpx"
              v-model="databangding.real_name" />
          </view>
        </view>
        <view class='flex flex-wrap align-center justify-center bindWechat_fd1_1'>
          <button class='bindWechat_fd1_1_c0' @tap.stop="queryListFunc()">提交</button>
        </view>
      </view>

      <!---绑定flex布局结束-->


    </view>
  </view>
</template>
<script>
  import UploadImage from '@/common/utils/upload-image.js'
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},


    data() {
      return {
        "dataMessage": {
          "invite_code": "",
          "address": "",
          "address_code": "",
          "hobby": "",
          "tags": "",
          "id": "",
          "userlevel_id": "",
          "mobile": "",
          "real_name": "",
          "avatar": "",
          "account": "",
          "email": "",
          "birthday": "",
          "gender": "",
          "create_time": "",
          "user_money": "",
          "freeze_money": "",
          "total_consumption_money": "",
          "score": "",
          "_mobile": "",
          "coupon": "",
          "collection_count": "",
          "browse_count": "",
          "total_money": "",
          "certified": "",
          "nickname": "",
          "is_pay_password": "",
          "follow_count": ""
        },
        "databangding": {
          "aid": "",
          "is_default": "",
          "create_time": "",
          "update_time": "",
          "status": "",
          "real_name": "",
          "account": "",
          "qrcode_url": "",
          "bank_name": "",
          "bank_address": "",
          "remark": ""
        },
        "code": "",
        "type": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        type
      } = options
      if (type !== undefined) this.type = type
      this.getUserinfoFunc()
      this.getbangdingtsFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //上传单图、多图方法
      soloChooseImage(id, path, obj, obj1, fnName = false) {
        let self = this
        if (!obj) obj = this
        if (!obj1) obj1 = this
        if (self.uploading) {
          return
        }
        // 从相册中选择图片
        uni.chooseImage({
          count: 1, // 默认3
          sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
          success: function(res) {
            self.uploading = true
            // 开始上传
            new UploadImage(res.tempFiles, {
              complete: function(res) {
                self.uploading = false
                if (id) self.$set(obj, id, res[0].id)
                if (path) self.$set(obj1, path, res[0].path)
                if (fnName) self[fnName]()
              },
            })
          },
        })
      },
      //获取会员详细信息
      async getUserinfoFunc() {
        //请求方法
        //数据验证

        let datadataMessage = await this.$api.get(global.apiUrls.post5c78c4772da97, {

        });

        if (datadataMessage.data.code != 1) {
          this.$message.info(datadataMessage.data.msg);
          return
        }
        let infodataMessage = datadataMessage.data;
        this.dataMessage = infodataMessage.data

      },
      //获取绑定信息
      async getbangdingtsFunc() {
        if (this.type == '1') {
          //请求方法
          //数据验证

          let datadatabangding = await this.$api.get(global.apiUrls.post636cbb376d5d8, {
            account_type: 'wx'
          });

          if (datadatabangding.data.code != 1) {
            this.$message.info(datadatabangding.data.msg);
            return
          }
          let infodatabangding = datadatabangding.data;
          this.databangding = infodatabangding.data

        }
      },
      //钱包-设置提现账户
      async queryListFunc() {
        if (!validate(this.code, 'require')) {
          this.$message.info('请输入验证码');
          return false;
        }
        if (!validate(this.code, 'require')) {
          this.$message.info('请输入正确的验证码');
          return false;
        }
        if (!validate(this.databangding.qrcode_url, 'require')) {
          this.$message.info('请上传二维码');
          return false;
        }
        if (!validate(this.databangding.real_name, 'require')) {
          this.$message.info('请输入真实姓名');
          return false;
        }
        //请求方法
        //数据验证

        let data5f6db4db8abcf = await this.$api.post(global.apiUrls.post5f6db4db8abcf, {
          mobile: this.dataMessage._mobile,
          code: this.code,
          type: '3'
        });

        if (data5f6db4db8abcf.data.code != 1) {
          this.$message.info(data5f6db4db8abcf.data.msg);
          return
        }



        //请求方法
        //数据验证

        let data636cc0cc8d6cc = await this.$api.dbPost(global.apiUrls.post636cc0cc8d6cc, {
          real_name: this.databangding.real_name,
          account_type: 'wx',
          qrcode_url: this.databangding.qrcode_url
        });
        if (!data636cc0cc8d6cc) return
        if (data636cc0cc8d6cc.data.code != 1) {
          this.$message.info(data636cc0cc8d6cc.data.msg);
          return
        }



        this.$message.info('微信绑定成功');
        setTimeout(() => {
          this.$urouter.navigateBack(1);
        }, 500)
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #F8F8F8;
    background-size: 100% auto;
  }

  .bindWechat_flex_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .bindWechat_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: #333;
  }

  .bindWechat_fd0_0_c0_c0 {
    font-size: 32rpx;
    font-weight: 500;
    color: #333;
  }

  .bindWechat_fd0_0_c0 {
    width: 180rpx;
  }

  .bindWechat_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
  }

  .bindWechat_flex_1 {
    padding: 0rpx 0rpx 150rpx 0rpx;
  }

  .bindWechat_fd1_1_c0 {
    background: var(--benbenbgColor2);
    border-radius: 40rpx 40rpx 40rpx 40rpx;
    font-size: 32rpx;
    color: var(--benbenFontColor3);
    width: 686rpx;
    height: 80rpx;
    line-height: 80rpx;
    font-weight: 700;
  }

  .bindWechat_fd1_1 {
    width: 750rpx;
    position: fixed;
    left: 0rpx;
    bottom: calc(40rpx + var(--window-bottom));
  }

  .bindWechat_fd1_0_c6_c0 {
    font-size: 28rpx;
    font-weight: 400;
    color: rgba(102, 102, 102, 1);
    margin: 0rpx 32rpx 0rpx 0rpx;
  }

  .bindWechat_fd1_0_c6 {
    padding: 0rpx 0rpx 32rpx 0rpx;
    line-height: 48rpx;
  }

  .bindWechat_fd1_0_c4_c1 {
    font-size: 28rpx;
    font-weight: 400;
    color: rgba(102, 102, 102, 1);
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .bindWechat_fd1_0_c4_c0_c0_icon {
    top: 0rpx;
    right: 0rpx;
    z-index: 10;
    color: #ff5536;
  }

  .bindWechat_fd1_0_c4_c0_c0 {
    width: 160rpx;
    height: 160rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
  }

  .bindWechat_fd1_0_c4 {
    border-bottom: 1px solid #eee;
    padding: 0rpx 0rpx 32rpx 0rpx;
    margin: 0rpx 0rpx 40rpx 0rpx;
  }

  .bindWechat_fd1_0_c3 {
    margin: 40rpx 0rpx 32rpx 0rpx;
  }

  .bindWechat_fd1_0_c2_c2 {
    text-align: center;
    font-size: 28rpx;
    color: var(--benbenFontColor4);
    font-weight: 400;
  }

  .bindWechat_fd1_0_c2_c1 {
    font-size: 28rpx;
    font-weight: 400;
    color: rgba(51, 51, 51, 1);
  }

  .bindWechat_fd1_0_c2_c0 {
    font-size: 28rpx;
    font-weight: 400;
    color: rgba(102, 102, 102, 1);
    margin: 0rpx 24rpx 0rpx 0rpx;
  }

  .bindWechat_fd1_0_c2 {
    border-bottom: 1px solid #eee;
    padding: 0rpx 0rpx 32rpx 0rpx;
  }

  .bindWechat_fd1_0_c1_c0 {
    font-size: 28rpx;
    font-weight: 400;
    color: rgba(102, 102, 102, 1);
  }

  .bindWechat_fd1_0_c1 {
    margin: 0rpx 0rpx 32rpx 0rpx;
  }

  .bindWechat_fd1_0_c0_c0 {
    font-size: 28rpx;
    font-weight: 500;
    color: rgba(51, 51, 51, 1);
  }

  .bindWechat_fd1_0_c0 {
    padding: 40rpx 0rpx 32rpx 0rpx;
  }

  .bindWechat_fd1_0 {
    background: var(--benbenbgColor1);
    padding: 0rpx 32rpx 0rpx 32rpx;
    background-size: 100% auto !important;
  }
</style>
